package setting

import "gopkg.in/ini.v1"

var Conf = new(AppConfig)

type AppConfig struct {
	Release      bool   `ini:"release"`
	HttpPort     string `ini:"httpPort"`
	*MySQLConfig `ini:"mysql"`
	*RedisConfig `ini:"redis"`
}

// MySQLConfig 数据库配置
type MySQLConfig struct {
	User     string `ini:"user"`
	Password string `ini:"password"`
	DataBase string `ini:"database"`
	Host     string `ini:"host"`
	Port     int    `ini:"port"`
}

// RedisConfig Redis缓存配置
type RedisConfig struct {
	RedisAddr string `ini:"redisAddr"`
	DBName    string `ini:"dbName"`
}

func Init(file string) error {
	return ini.MapTo(Conf, file)
}
